package gth.news.dto;

import gth.news.domain.News;
import gth.utils.DateUtils;

public class NewsDto {
    private Integer id;
    private String title;
    private String content;
    private String insertDate;
    private String updateDate;

    public static NewsDto toDto(News news){
        NewsDto dto = new NewsDto();
        dto.setContent(news.getContent());
        dto.setTitle(news.getTitle());
        dto.setId(news.getId());
        dto.setInsertDate(DateUtils.formatDateToString(news.getInsertDate(),"yyyy-MM-dd hh:mm"));
        if(news.getUpdateDate()!=null) {
            dto.setUpdateDate(DateUtils.formatDateToString(news.getUpdateDate(), "yyyy-MM-dd hh:mm"));
        }
        return dto;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getInsertDate() {
        return insertDate;
    }

    public void setInsertDate(String insertDate) {
        this.insertDate = insertDate;
    }

    public String getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }
}
